﻿<?php 
error_reporting(E_ALL);
ini_set('display_errors', '1');
// include db config
include_once("config.php");
	ob_start();
// set up DB

$db_conf = array();

$db_conf["type"] = "mysqli";

$db_conf["server"] = "localhost"; // or you mysql ip

$db_conf["user"] = "root"; // username

$db_conf["password"] = ""; // password

$db_conf["database"] = "1707_eade"; // database
// include and create object
$base_path = strstr(realpath("."),"demos",true)."lib/";
include("./lib/inc/jqgrid_dist.php");
$g = new jqgrid($db_conf);

$col = array();
$col["title"] = "Id"; // caption of column
$col["name"] = "id"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col["width"] = "10";
$col["hidden"] = true;
$cols[] = $col;        

$col = array();
$col["title"] = "Nombre";
$col["name"] = "nombre";
$col["editable"] = false; // this column is not editable
$col["search"] = true; // this column is not searchable
$col["sortable"] = true;
$cols[] = $col;

$col = array();
$col["title"] = "Dni";
$col["name"] = "dniAl";
$col["width"] = "60";
$col["sortable"] = true; // this column is not sortable
$col["search"] = true; // this column is not searchable
$col["editable"] = false;
$cols[] = $col;
//Pagado
$col = array();
$col["title"] = "Pagado";
$col["name"] = "pagado";
$col["editable"] = true;
$col["search"] = false; // this column is not searchable
$col["width"] = "35";
$col["edittype"] = "checkbox"; 
$col["align"] = "center"; 
$col["editoptions"] = array("value"=>"1:0");
$cols[] = $col;

$mysqli = new mysqli("localhost", "root", "", "1707_eade");
$cargos = $mysqli->query("select nombre as nombreCurso,ndias from entradas where id=".$_GET['idCurso']."");
$sql ="select c.pagado,c.id, concat(a.nombre,' ',a.apellidos) as nombre, p.dniAl,c.comentario";
$cargo = $cargos->fetch_row();
for($x=1;$x<$cargo[1]+1;$x++){
	for($y=1;$y<3;$y++){
		$col = array();
		$col["title"] = "D".$x."T".$y;
		$col["name"] = "dia".$x.$y;
		$col["editable"] = true;
		$col["search"] = false; // this column is not searchable
		$col["width"] = "35";
		$col["edittype"] = "checkbox"; 
        $col["align"] = "center"; 
		$col["editoptions"] = array("value"=>"1:0");
		$cols[] = $col; 
		$sql.=",dia".$x.$y;
	}
}

$col = array();
$col["title"] = "Comentario";
$col["name"] = "comentario";
$col["sortable"] = false; // this column is not sortable
$col["search"] = false; // this column is not searchable
$col["editable"] = true;
$cols[] = $col;
//Dossier
$col = array();
$col["title"] = "Dossier";
$col["name"] = "dossier";
$col["editable"] = true;
$col["search"] = false; // this column is not searchable
$col["width"] = "35";
$col["edittype"] = "checkbox"; 
$col["align"] = "center"; 
$col["editoptions"] = array("value"=>"1:0");
$cols[] = $col;


$sql.=",dossier FROM control_curso as c join inscripciones p on (c.idParticipante = p.id) join alumnos as a on (a.dni = p.dniAl) WHERE p.ncurso = ".$_GET["idCurso"];

$grid["rowNum"] = 30; // by default 20
$grid["sortname"] = 'id'; // by default sort grid by this field
$grid["sortorder"] = "desc"; // ASC or DESC
$grid["caption"] = "Invoice Data"; // caption of grid
$grid["autowidth"] = true; // expand grid to screen width
$grid["multiselect"] = true; // allow you to multi-select through checkboxes

$grid["altRows"] = true; 
$grid["altclass"] = "myAltRowClass"; 

$grid["rowactions"] = true; // allow you to multi-select through checkboxes

// export XLS file
// export to excel parameters
$grid["export"] = array("format"=>"pdf", "filename"=>"my-file", "sheetname"=>"test");

// RTL support
//$grid["direction"] = "rtl";

$g->set_options($grid);

$g->set_actions(array(    
                        "add"=>false, // allow/disallow add
                        "edit"=>true, // allow/disallow edit
                        "delete"=>false, // allow/disallow delete
                        "rowactions"=>true, // show/hide row wise edit/del/save option
                        "export"=>false, // show/hide export to excel option
                        "autofilter" => true, // show/hide autofilter for search
                        "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
                    ) 
                );

// you can provide custom SQL query to display data
$g->select_command = $sql;

// this db table will be used for add,edit,delete
$g->table = "control_curso";
// pass the cooked columns to grid
$g->set_columns($cols);

// generate grid output, with unique grid name as 'list1'
$out = $g->render("list1");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>EADE Consulting J.E.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Pagina web de EADE Consulting" />
<meta name="keywords" content="EADE, Junior Empresa, Junior empresa castellon, uji,CEJE," />
<link rel="shortcut icon" href="http://www.eade.localhost/imagenes/fotos/eade.png"/>
    <link rel="stylesheet" type="text/css" media="screen" href="http://<?php echo $_SERVER['SERVER_NAME'];?>/phpgrid/lib/js/themes/redmond/jquery-ui.custom.css"></link>    
    <link rel="stylesheet" type="text/css" media="screen" href="http://<?php echo $_SERVER['SERVER_NAME'];?>/phpgrid/lib/js/jqgrid/css/ui.jqgrid.css"></link>    
    <script src="http://<?php echo $_SERVER['SERVER_NAME'];?>/phpgrid/lib/js/jquery.min.js" type="text/javascript"></script>
    <script src="http://<?php echo $_SERVER['SERVER_NAME'];?>/phpgrid/lib/js/jqgrid/js/i18n/grid.locale-es.js" type="text/javascript"></script>
    <script src="http://<?php echo $_SERVER['SERVER_NAME'];?>/phpgrid/lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
    <script src="http://<?php echo $_SERVER['SERVER_NAME'];?>/phpgrid/lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
</head>
<body> 
    <style>
    .myAltRowClass { background-color: #DDDDDC; background-image: none; }
    </style>
	<div id="page">
		<div id="logo"><a href="http://www.eade.localhost"><img src="http://<?php echo $_SERVER['SERVER_NAME'];?>/listados/imagenes/logo.gif"/></a><div style="float:right;text-align:right;margin-rigth:-40px;margin-top:15px;"><div class="fb-like-box" data-href="http://www.facebook.com/pages/EADE-Consulting-JE/191938220858819" data-width="250" data-show-faces="false" data-stream="false" data-header="true"></div></div></div>
		<div id="header">
			<h2> <?php echo $cargo[0]; ?></h2>
		</div>
		<div id="cuerpo">
			<div style="margin:10px">
			<?php echo $out?>
			</div>
		</div>
	 </div>         
</body>
</html> 